package com.mkl.ttxt.common.constant;

import com.mkl.ttxt.common.exception.BusinessException;
import com.mkl.ttxt.pd.dao.IBoxDao;
import com.mkl.ttxt.pd.dao.IPdDao;
import com.mkl.ttxt.pd.util.PlanUtil;
import io.netty.util.internal.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BaseConstant {

    @Autowired
    private static IBoxDao iBoxDao;

    @Autowired
    public BaseConstant(IBoxDao iBoxDao) {
        BaseConstant.iBoxDao = iBoxDao;
    }

    public static final Integer SUCCESS = 0;
    public static final Integer FAILED = 1;
    public static final Integer LOGIN_FAILED = 401;

    public int BLOOD_LINE = 20;//尾刀血线单位w

    public Integer MAGNIFICATION_11 = 10;//1王分数倍率
    public Integer MAGNIFICATION_12 = 10;//2王分数倍率
    public Integer MAGNIFICATION_13 = 10;//3王分数倍率
    public Integer MAGNIFICATION_14 = 10;//4王分数倍率
    public Integer MAGNIFICATION_15 = 10;//5王分数倍率
    public Integer MAGNIFICATION_16 = 10;//6王分数倍率
    public Integer MAGNIFICATION_21 = 10;//1王分数倍率
    public Integer MAGNIFICATION_22 = 11;//2王分数倍率
    public Integer MAGNIFICATION_23 = 15;//3王分数倍率
    public Integer MAGNIFICATION_24 = 12;//4王分数倍率
    public Integer MAGNIFICATION_25 = 20;//5王分数倍率
    public Integer MAGNIFICATION_26 = 18;//6王分数倍率
    public Integer MAGNIFICATION_31 = 0;//1王分数倍率
    public Integer MAGNIFICATION_32 = 0;//2王分数倍率
    public Integer MAGNIFICATION_33 = 0;//3王分数倍率
    public Integer MAGNIFICATION_34 = 0;//4王分数倍率
    public Integer MAGNIFICATION_35 = 0;//5王分数倍率
    public Integer MAGNIFICATION_36 = 0;//6王分数倍率

    public static int COMPOSE_NUM = 50;//调整保留收益最高的N个阵容
    public static int DIF_COMPOSE_REPEAT = 0;//两个组合间，若有x个不同，视为不同组合
    public static Integer REPLY_OVERFLOW = 120;//回复时溢出最大值
    public static int TEMPFILE_MEMBER_NUM = 22;//排了N人之后输出临时文件

    public void loadBloodParam(Integer userId){
        if(StringUtil.isNullOrEmpty(iBoxDao.getParam(userId, "尾刀血线"))){
            throw new BusinessException("参数未初始化");
        }
        this.BLOOD_LINE = Integer.valueOf(iBoxDao.getParam(userId, "尾刀血线"));
    }

    public void loadScoreParam(Integer userId){
        if(StringUtil.isNullOrEmpty(iBoxDao.getParam(userId, "二阶段1王分数倍率"))){
            throw new BusinessException("参数未初始化");
        }
        this.MAGNIFICATION_11 = Integer.valueOf(iBoxDao.getParam(userId, "一阶段1王分数倍率"));
        this.MAGNIFICATION_12 = Integer.valueOf(iBoxDao.getParam(userId, "一阶段2王分数倍率"));
        this.MAGNIFICATION_13 = Integer.valueOf(iBoxDao.getParam(userId, "一阶段3王分数倍率"));
        this.MAGNIFICATION_14 = Integer.valueOf(iBoxDao.getParam(userId, "一阶段4王分数倍率"));
        this.MAGNIFICATION_15 = Integer.valueOf(iBoxDao.getParam(userId, "一阶段5王分数倍率"));
        this.MAGNIFICATION_16 = Integer.valueOf(iBoxDao.getParam(userId, "一阶段6王分数倍率"));
        this.MAGNIFICATION_21 = Integer.valueOf(iBoxDao.getParam(userId, "二阶段1王分数倍率"));
        this.MAGNIFICATION_22 = Integer.valueOf(iBoxDao.getParam(userId, "二阶段2王分数倍率"));
        this.MAGNIFICATION_23 = Integer.valueOf(iBoxDao.getParam(userId, "二阶段3王分数倍率"));
        this.MAGNIFICATION_24 = Integer.valueOf(iBoxDao.getParam(userId, "二阶段4王分数倍率"));
        this.MAGNIFICATION_25 = Integer.valueOf(iBoxDao.getParam(userId, "二阶段5王分数倍率"));
        this.MAGNIFICATION_26 = Integer.valueOf(iBoxDao.getParam(userId, "二阶段6王分数倍率"));
        this.MAGNIFICATION_31 = Integer.valueOf(iBoxDao.getParam(userId, "三阶段1王分数倍率"));
        this.MAGNIFICATION_32 = Integer.valueOf(iBoxDao.getParam(userId, "三阶段2王分数倍率"));
        this.MAGNIFICATION_33 = Integer.valueOf(iBoxDao.getParam(userId, "三阶段3王分数倍率"));
        this.MAGNIFICATION_34 = Integer.valueOf(iBoxDao.getParam(userId, "三阶段4王分数倍率"));
        this.MAGNIFICATION_35 = Integer.valueOf(iBoxDao.getParam(userId, "三阶段5王分数倍率"));
        this.MAGNIFICATION_36 = Integer.valueOf(iBoxDao.getParam(userId, "三阶段6王分数倍率"));
    }
}
